package com.ht.demo.action;

import javax.servlet.ServletRequest;

import org.apache.struts2.ServletActionContext;

import com.ht.demo.entity.TestWorkFlow;
import com.ht.right.entity.BaseEntity;
import com.ht.right.service.CommonFacadeService;
import com.ht.right.util.CommonUtil;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class TestWorkFlowAction extends ActionSupport implements ModelDriven<BaseEntity>{

	private static final long serialVersionUID = 1L;
	//private TestWorkFlow testWorkFlow;
	private BaseEntity testWorkFlow;
	private CommonFacadeService<BaseEntity> commonFacadeService;
	
	/*
	@Override
	public TestWorkFlow getModel() {
		if(CommonUtil.isNullOrEmpty(testWorkFlow)){
			testWorkFlow = new TestWorkFlow();
		}
		return testWorkFlow;
	}
	
	public TestWorkFlow getTestWorkFlow() {
		return testWorkFlow;
	}
	public void setTestWorkFlow(TestWorkFlow testWorkFlow) {
		this.testWorkFlow = testWorkFlow;
	}
	
	*/
	public String addWorkFlowInfo(){
		ServletRequest request = ServletActionContext.getRequest();
		String rightId = request.getParameter("menuId");
		commonFacadeService.save(testWorkFlow, rightId);
		return "success";
	}



	public BaseEntity getTestWorkFlow() {
		return testWorkFlow;
	}



	public void setTestWorkFlow(BaseEntity testWorkFlow) {
		this.testWorkFlow = testWorkFlow;
	}



	public CommonFacadeService<BaseEntity> getCommonFacadeService() {
		return commonFacadeService;
	}

	public void setCommonFacadeService(CommonFacadeService<BaseEntity> commonFacadeService) {
		this.commonFacadeService = commonFacadeService;
	}

	@Override
	public BaseEntity getModel() {
		if(CommonUtil.isNullOrEmpty(testWorkFlow)){
			testWorkFlow = new TestWorkFlow();
		}
		return testWorkFlow;
	}


}
